﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace NutriLeaf.Phone.Core.Weight
{
    public class Converter
    {
        public static decimal Convert(decimal value, WeightUnits from, WeightUnits to)
        {
            if (from == to)
            {
                return value;
            }

            if (from == WeightUnits.Kilograms && to == WeightUnits.Pounds)
            {
                return (decimal)(value * (decimal)2.20492);
            }

            if (from == WeightUnits.Pounds && to == WeightUnits.Kilograms)
            {
                return (decimal)(value * (decimal)0.45359);
            }
            return 0;
        }

        public static decimal ConvertToPounds(decimal value)
        {
            return Convert(value, WeightUnits.Kilograms, WeightUnits.Pounds);
        }

        public static decimal ConvertToKilograms(decimal value)
        {
            return Convert(value, WeightUnits.Pounds, WeightUnits.Kilograms);
        }
    }
}